package day_2022_7_to_8.day48;

/**
 * @author haomin
 * @date 2022/09/02 21:33
 **/
public class Day48_5_Offer39_MajorityElement {
    class Solution {
        public int majorityElement(int[] nums) {
            int num = 1, value = nums[0];
            for(int i = 1; i < nums.length; ++i){
                if(num == 0) value = nums[i];
                if(value == nums[i]) num++;
                else num--;
            }
            return value;
        }
    }
}